<script>
export default {
  name: "myinfo",
  data() {
    return {
      form: {
        id: '',
        staff_remark: '',
        fileList: []
      },
      action:  this.$baseUrl + '/api/upload/file',
      fileList: []
    }
  },
  onLoad({ id }) {
    this.form.id = id
  },
  methods: {
    successFile(e) {
      this.form.fileList.push(e.data.url)
    },
    removeFile(index) {
      this.form.fileList.splice(index, 1)
    },
    submit() {
      this.$api.confirmOrder({
        ...this.form,
        staff_id: this.$store.state.userInfo.id
      }).then(() => {
        uni.showToast({
          title: '已送达',
          icon: 'none',
          duration: 2000
        })
        setTimeout(() => {
          uni.navigateBack()
        })
      })
    },
    logout() {
      uni.showModal({
        title: '提示',
        content: '确定退出登录？',
        success: (res) => {
          if (res.confirm) {
            this.$store.commit('SET_USERINFO', {})
            uni.navigateTo({
              url: '/pages/user/login'
            })
          }
        }
      })
    }
  }
}
</script>

<template>
  <div class="myinfo">
    <div class="form-box">
      <u-form :model="form" ref="uForm" label-position="top">
        <u-form-item label="备注"><u-input v-model="form.staff_remark" type="textarea" /></u-form-item>
        <u-form-item label="图片">
          <u-upload :action="action" max-count="99" :file-list="fileList" @on-success="successFile" @on-remove="removeFile"></u-upload>
        </u-form-item>
      </u-form>
    </div>
    <div class="button button-primary" style="margin: 30rpx 0;width: 100%" @click="submit" >保存</div>
  </div>
</template>

<style lang="scss">
.myinfo {
  height: 100%;
  background-color: #F5F7FA;
  padding: 20rpx;
  .primary-button {
    margin-top: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 41px;
    line-height: 41px;
    font-size: 16px;
    color: #fff;
    background-color: #2aac34;
    border-radius: 5px;
    box-sizing: border-box;
  }
  .form-box {
    border-radius: 10px;
    background-color: #FFFFFF;
    padding: 20rpx;
  }
}
</style>
